home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000087_icon-group-sender _Mon Oct 20 12:33:06 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by cheltenham.cs.arizona.edu (8.8.7/8.8.7) with SMTP id MAA28725
for <icon-group-addresses@cheltenham.CS.Arizona.EDU>; Mon, 20 Oct 1997 12:33:06 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA19468; Mon, 20 Oct 1997 12:33:05 -0700
From: gep2@computek.net
Date: Mon, 20 Oct 1997 12:11:29 -0500
Message-Id: <199710201711.MAA10989@axp.cmpu.net>
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Subject: counting letters
To: icon-group@cs.arizona.edu
X-Mailer: SPRY Mail Version: 04.00.06.17
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
>What would be the best way to design an Icon program that takes a text
file as input, counts up the instances of every letter in the alphabet
(ignoring other characters and distinguishing between uppercase and
lowercase letters), and spits out the results of the count as output?
Define "best"... smallest, simplest, fastest, most elegant?
>For example, the following input
abcdefghjijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()
would produce the following output
>a 1
b 2
[etc.]
A 1
b 2
[etc.]
[nothing for the non-alphabetic characters]
In SNOBOL4+/SPITBOL, one program would be:
-PLUSOPS 1
T = TABLE()
CHRSET = &LCASE &UCASE
GETREC LINE = INPUT :F(EOF)
COUNT LINE BREAK(CHRSET) ANY(CHRSET) . LET = ?(T[LET] = T[LET] + 1)
+ :S(COUNT)F(GETREC)
EOF A = SORT(TABLE,1) :F(DONE)
LIST OUTPUT = A[(N = N + 1),1] " " A[N,2] :S(LIST)
END
Gordon Peterson
http://www.computek.net/public/gep2/
Support the Anti-SPAM Amendment! Join at http://www.cauce.org/